package lambdad;
//无返回值无参数

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

@FunctionalInterface

interface NoParameterNoReturn {
 void test();
}

//无返回值一个参数

@FunctionalInterface

interface OneParameterNoReturn {
 void test(int a);
}

//无返回值多个参数

@FunctionalInterface

interface MoreParameterNoReturn {
 void test(int a,int b);
}

//有返回值无参数

@FunctionalInterface

interface NoParameterReturn {
 int test();
}




//有返回值一个参数

@FunctionalInterface

interface OneParameterReturn {
 int test(int a);
}

//有返回值多参数

@FunctionalInterface

interface MoreParameterReturn {

    int test(int a, int b);
}
public class Test {

    public static void main1(String[] args) {
      /*  NoParameterNoReturn noParameterNoReturn = ()->{
            System.out.println("测试一下");
        };
        noParameterNoReturn.test();
        OneParameterNoReturn oneParameterNoReturn=(int a)->{
            System.out.println(a);
        };

        oneParameterNoReturn.test(5);
        MoreParameterNoReturn moreParameterNoReturn=(int a,int b)->{
            System.out.println(a+b);
        };*/
//        moreParameterNoReturn.test(5,6);
        /*NoParameterReturn noParameterReturn=()->{return 0;};
        int val=noParameterReturn.test();
        System.out.println(val);*/
      /*  OneParameterReturn oneParameterReturn = (int a)->{return a;};
       int ret= oneParameterReturn.test(5);
        System.out.println(ret);*/
        /*MoreParameterReturn moreParameterReturn = (int a,int b)->{return a+b;};
        int ret= moreParameterReturn.test(8,4);
        System.out.println(ret);*/
    }

    public static void main2(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("fello");
        list.add("bit");
        list.add("hello");
        list.add("lambda");
        /*list.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });
        list.forEach(s-> System.out.println(s));*/
       /* list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o2.compareTo(o1);
            }
        });*/
//        list.sort((str1,st2)-> str1.length()-st2.length() );
        list.sort((str1,str2)->str1.compareTo(str2));
        list.forEach(s-> System.out.println(s));
    }

    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
          map.put(1, "hello");
          map.put(2, "bit");
          map.put(3, "hello");
          map.put(4, "lambda");
         /* map.forEach(new BiConsumer<Integer, String>() {
              @Override
              public void accept(Integer integer, String s) {
                  System.out.println("key:  "+s+  "val:   "+integer);
              }
          });*/
          map.forEach((val,s)->System.out.println("key:  "+s+  "val:   "+val));
    }

}
